package ro.noelx.connections.ui;

import ro.noelx.android.tools.ui.EntityAdapter;
import ro.noelx.connections.R;
import ro.noelx.connections.model.Person;
import ro.noelx.connections.model.Relation;
import ro.noelx.connections.model.Verb;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class RelationListAdapter extends EntityAdapter<Verb> {

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		View view = inflater.inflate(R.layout.relation_list_multi_line_list_item, null);

		final Relation relation = (Relation) getItem(position);

		Person person1 = relation.getPerson1();
		if (person1 != null) {
			TextView person1Text = (TextView) view.findViewById(R.id.person1);
			person1Text.setText(person1.getName());
		}

		Verb verb = relation.getVerb();
		if (verb != null) {
			TextView verbText = (TextView) view.findViewById(R.id.verb);
			verbText.setText(relation.getVerb().getValue());
		}
		
		Person person2 = relation.getPerson2();
		if (person2 != null) {
			TextView person2Text = (TextView) view.findViewById(R.id.person2);
			person2Text.setText(person2.getName());
		}
		// if (longClickMenuItem.getOnClickListener() != null) {
		// view.setOnClickListener(longClickMenuItem.getOnClickListener());
		// }
		return view;

	}

}
